package com.msb.mall.order.entity.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class OrderConfirmVo {

    //订单的收货人地址
    private List<MemberAddressVo> address;
    //购物车选中的商品信息
    private List<OrderItemVo> items;

    //支付方式

    //发票信息

    //优惠信息

    private String orderToken;

    public Integer getCountNum(){
       int count = 0;
       if(items != null){
           for (OrderItemVo item :items) {
               count += item.getCount();
           }
       }
        return count;
    }
    //    //总的金额
    public BigDecimal getTotal(){
        BigDecimal sum = new BigDecimal(0);
        if(items != null){
            for (OrderItemVo item :items) {
                BigDecimal totalPrice = item.getPrice().multiply(new BigDecimal(item.getCount()));
                sum = sum.add(totalPrice);
            }
        }
        return sum;
    }

    //需要支付的总金额
    public BigDecimal getPayTotal(){
        BigDecimal sum = new BigDecimal(0);
        if(items != null){
            for (OrderItemVo item :items) {
                BigDecimal totalPrice = item.getPrice().multiply(new BigDecimal(item.getCount()));
                sum = sum.add(totalPrice);
            }
        }
        return sum;
    }


}
